from .wrapData import (
    wrapRelationshipDivideData
)
def convertNode(node):
    result = {}
    result['label'] = str(node.labels)
    keys = node.keys()
    for key in keys:
        result[key] = node[key]
    return result

def convertRelationship(relationship):
    result = dict({})
    keys = relationship.keys()
    for key in keys:
        result[key] = relationship[key]
    return result

# 处理多条边
def convertRelationshipsToNodeAndRelationship(relationships):
    relationshipsArr = []
    for relationship in relationships:
        start_node_data = convertNode(relationship.start_node)
        end_node_data = convertNode(relationship.end_node)
        relationship_data = convertRelationship(relationship)
        tempDict = wrapRelationshipDivideData(start_node = start_node_data, end_node = end_node_data, relationship = relationship_data)
        relationshipsArr.append(tempDict)
    return relationshipsArr

